package com.micro.utils;

import lombok.extern.slf4j.Slf4j;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author micro
 * @date 2021-10-15 10:14:10
 * @description
 */
@Slf4j
public class FileUtils {
    /**
     * 写到文件
     *
     * @param fileName
     * @param bytes
     * @throws IOException
     */
    public static void writeBytesToFile(String fileName, byte[] bytes) throws IOException {
        File file = new File(fileName);
        //创建目录
        file.getParentFile().mkdirs();
        try (FileOutputStream fos = new FileOutputStream(file)) {
            fos.write(bytes);
            fos.flush();
        } catch (Exception e) {
            log.info("写出流异常：{}", e);
        }
    }
}
